/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A 
 * copy of the license can be found in the License.html file at the root of this distribution. If 
 * you cannot locate the  Microsoft Public License, please send an email to 
 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
 * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
 * PARTICULAR PURPOSE.
 * ***************************************************************************/


// StaticDlg.cpp : implementation file
//

#include "stdafx.h"
#include "testpgl.h"
#include "StaticDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CStaticDlg dialog


CStaticDlg::CStaticDlg(CWnd* pParent /*=NULL*/, CPGLRegionPtr pRegion)
	: CDialog(CStaticDlg::IDD, pParent), m_pglstatic(pRegion)
{
	//{{AFX_DATA_INIT(CStaticDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	
}


void CStaticDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CStaticDlg)
	DDX_Control(pDX, IDC_STATIC_PGL, m_pglstatic);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CStaticDlg, CDialog)
	//{{AFX_MSG_MAP(CStaticDlg)
	ON_BN_CLICKED(IDC_BUTTON_REDRAW, OnButtonRedraw)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CStaticDlg message handlers

BOOL CStaticDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	m_pglstatic.SetRegion(((CTestpglApp*)AfxGetApp())->GenerateRegion());

	CPGLRegionPtr pRegion = m_pglstatic.GetRegion();

	CPGLRectD rExt( 0, //left     
		0, // bottom     
		10, // right     
		1); // top

	// Zoom world region
	pRegion->ZoomRegion(     
		m_pglstatic.GetGfxInterface(), // get the graphic interface   
		rExt     );

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}


void CStaticDlg::OnButtonRedraw() 
{
	m_pglstatic.GetRegion()->GetChild(0)->GetAxe()->SetTitle(
		_T("Redrawed:")+COleDateTime::GetCurrentTime().Format(_T("%m/%d/%Y, %H:%M:%S") ) );

	m_pglstatic.SetDirty();
}
